-
Notifications
You must be signed in to change notification settings - Fork 661
fix: #2463 update event handling for field-bitmap to support touch #2492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: #2463 update event handling for field-bitmap to support touch #2492
Conversation
…p to support touch This includes debug logging. A followup commit will remove the debugging.
|
Use |
|
Hi @mikeharv I made a fix to the bitmap editor based on your change. If you have some time would you mind taking a look to make sure I'm not missing anything? |
| * @param e The down event. | ||
| */ | ||
| private onPointerStart(e: PointerEvent) { | ||
| const currentElement = document.elementFromPoint(e.clientX, e.clientY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does e.target not work here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in onPointerMove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Touch events get captured by the element they start on. This means the target is always the element the event started on, so it won't change when you drag across another pixel cell.
|
For completeness, I did find an alternate to using elementFromPoint() would be to cast the target in the pointerdown event to an Element and call releasePointerCapture(). This might have a slight performance advantage, but both options work well so it's not worth revisiting unless we find an issue with the current approach. |
The basics
The details
Resolves
Fixes #2463 by changing how the editor handles mouse and touch events.
Proposed Changes
Updates the Bitmap field to properly support touch events. This change is based on code-dot-org/code-dot-org#61709 .
Screen.recording.2025-02-21.9.59.31.AM.webm
Reason for Changes
Touch events in the bitmap editor would get canceled by the browser, causing the gesture to end early and the state to not be cleaned up properly. This would cause Blockly to become partially unresponsive.
Test Coverage
Tested manually on a Chromebook with a touch screen.
Documentation
Additional Information